package com.hmys.api.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hmys.api.mapper.WebStateMapper;
import com.hmys.api.model.WebState;
import com.hmys.api.service.WebStateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * Created by chen365 on 2018/04/09.
 */
@Service
public class WebStateServiceImpl implements WebStateService {
    @Autowired
    private WebStateMapper webStateMapper;
    @Override
    public PageInfo<WebState> selectByBean(Integer pageIndex, Integer pageSize, WebState record) {
        if (StringUtils.isEmpty(pageIndex) || pageIndex < 1) {
            pageIndex = 1;
        }
        if (StringUtils.isEmpty(pageSize) || pageSize < 1) {
            pageSize = 10;
        }
        PageHelper.startPage(pageIndex, pageSize);
        List<WebState> list = webStateMapper.selectByBean(record);
        return new PageInfo<>(list);
    }
}
